package com.baor.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baor.dao.ActivityDao;
import com.baor.domain.Activity;
import com.baor.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ActivityServiceimpl implements ActivityService {
    @Autowired
    private ActivityDao activityDao;
    @Override
    public List<Activity> jinru() {
        List<Activity> jin =activityDao.selectList(null);
        return jin;
    }

    @Override
    public int cr(Activity activity) {
        int row = activityDao.insert(activity );
        return row;
    }

    @Override
    public int bj(Activity activity) {
        UpdateWrapper<Activity> wrapper = new UpdateWrapper<Activity>()
                .eq("id", activity.getId())
                .set(activity.getActivityName() != null, "activity_name", activity.getActivityName())
                .set(activity.getSignTime() != null, "sign_time", activity.getSignTime())
                .set(activity.getPrice() != null, "price", activity.getPrice())
                .set(activity.getContent() != null, "content", activity.getContent())
                .set(activity.getIsShow() != null, "is_show", activity.getIsShow())
                .set(activity.getUpdatedAt() != null, "updated_at", activity.getUpdatedAt())
                .set(activity.getIsDeleted() != null, "is_deleted", activity.getIsDeleted());
        int hang = activityDao.update(null, wrapper);
        return hang;
    }
}
